package com.chainyoung.component_tmperson.ui.mvp.presenter;

import com.chainyoung.common.appcommon.entity.UploadFile;
import com.chainyoung.common.base.CommonSubscriber;
import com.chainyoung.common.bean.UserInfo;
import com.chainyoung.common.di.scope.ActivityScope;
import com.chainyoung.common.mvp.BasePresenter;
import com.chainyoung.common.utils.RxUtils;
import com.chainyoung.common.utils.UpLoadUtils;
import com.chainyoung.component_tmperson.ui.mvp.contract.UpdatePwdContract;
import com.chainyoung.component_tmperson.ui.mvp.contract.UpdateUserInfoContract;

import java.util.TreeMap;

import javax.inject.Inject;

import okhttp3.RequestBody;

@ActivityScope
public class UpdatePwdPresenter extends BasePresenter<UpdatePwdContract.Model, UpdatePwdContract.View> {

    @Inject
    public UpdatePwdPresenter(UpdatePwdContract.Model model, UpdatePwdContract.View rootView) {
        super(model, rootView);
    }


    public void updatePwd(TreeMap<String, Object> map) {
        addSubscribe(mModel.updatePwd(map)
                .compose(RxUtils.<String>rxSchedulerHelper())
                .subscribeWith(new CommonSubscriber<String>(mView,true) {
                    @Override
                    public void onNext(String data) {
                        mView.updatePwdSuccess(data);
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                    }
                }));
    }

    public void sendCode(TreeMap<String, Object> map) {

        addSubscribe(mModel.getSendCode(map)
                .compose(RxUtils.<String>rxSchedulerHelper())
                .subscribeWith(new CommonSubscriber<String>(mView,true) {
                    @Override
                    public void onNext(String object) {
                        mView.onSendCodeSuccess(object);
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                    }
                }));
    }


}

